<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(function() {
            $("#subt").click(function() {

                $.ajax({
                    type: "post",
                    url: "/add",
                    data: {
                        name: $("#name").val(),
                        classId: 1
                    },
                    dataType: "json",
                    success: function(data) {
                        if(data == 1) {
                            alert("签到成功！");
                        } else if(data == 0) {
                            alert("签到失败！");
                        }
                    }
                });
            });


            $("#subt2").click(function() {

                $.ajax({
                    type: "post",
                    url: "/add",
                    data: {
                        name: $("#name").val(),
                        classId: 2
                    },
                    dataType: "json",
                    success: function(data) {
                        if(data == 1) {
                            alert("签到成功！");
                        } else if(data == 0) {
                            alert("签到失败！");
                        }
                    }
                });
            });
        });
    </script>

    <style>
        .box{
            border: 1px red solid;
            text-align:center;
            width: 500px;
            margin: auto;
        }

        table{
            text-align: center;
        }
    </style>
</head>
<body>

<div class="box">
    <a href="/selectAllIT"> <button type="button" value="IT3班签到查询">IT3班签到查询</button></a>
    <a href="/selectAllJAVA"> <button type="button" value="JAVA班签到查询">JAVA班签到查询</button></a>

    <table>
        <tr>
            <td>签到人数：</td>
            <td th:text="${count}"></td>
        </tr>
        <tr>
            <td>名字</td>
        </tr>
        <tr th:each="student:${list}">
            <td th:text="${student.name}"></td>
        </tr>
    </table>


    <p>名字：<input type="text" name="name" id="name"></p>
    <p>
        <button type="submit" id="subt" value="IT3班签到">IT3班签到</button>
        <button type="submit" id="subt2" value="JAVA班签到">JAVA班签到</button>
    </p>

</div>


</body>
</html>